package com.celestial.Repository;

import com.celestial.Domain.DTO.StartAndEndNodes;
import com.celestial.Domain.PO.Person;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PersonRepository extends Neo4jRepository<Person, Long> {

    @Query("MATCH (n:`人物`)-[r]-(m) WHERE n.name = :#{#personName} "
            + "RETURN n.name AS startNode, collect(r), collect(m.name) AS endNode, collect(type(r)) AS relation")
    StartAndEndNodes getPersonGraph(String personName);

    @Query("MATCH (n:`人物`) RETURN n.name")
    List<String> getAllPerson();
}
